<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//load class from file
function _lc() {
	$args = func_get_args();
	if( is_array($args) ) {
		foreach($args as $classfile) {
			if( strlen($classfile) > 0 && file_exists(CONFIG_PATH . CONFIG_DIR_CLASSES . $classfile) ) {
				include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . $classfile);
			}
		}
	}
}

//load class from class name
function _lcn() {

}

//create class object
function _co($classname) {
	if( class_exists($classname) ) {
		return new $classname();
	} else {
		die("CO " . $classname);
	}
	
	return NULL;
}

//html item type
function _comm_types() {
	$types = array(
		'string',
		'text',
		'hidden',
		'select',
		'status',
		'checkbox',
		'radio',
		'email',
		'password',
		'textarea',
		'file',
		'int',
		'float',
		'html',
		'postcode',
		'telephone',
		'date',
		'time',
		'zone',
		'country'
			);
	
	return $types;
}

//setting
function _setting($key, $isnew = false) {
	if( $isnew == true ) {
		global $settingObj;
		
		return $settingObj->getItemValue($key);
	} else {
		global $SETTINGS;
		
		if( isset($SETTINGS[$key]) ) {
			return $SETTINGS[$key];
		}
	}
	
	return '';
}

//message stack display
function _dms($msg) {
	global $messagestackObj;
	
	$messagestackObj->add_session('header', $msg);
}
//
?>